package jtk.project4.fleet.screen.autogeneratepo;

import java.awt.FlowLayout;

import jtk.project4.fleet.action.POSelectionAction;
import jtk.project4.fleet.field.AutoGeneratePOField;

import nl.coderight.jazz.action.Action;
import nl.coderight.jazz.form.FormHeader;
import nl.coderight.jazz.form.FormView;
import nl.coderight.jazz.form.control.GroupControl;
import nl.coderight.jazz.form.field.button.PushButton;

public class AutoGeneratePOView extends FormView{
	private FormHeader formHeader ;
	private PushButton cancelButton ;
	private PushButton submitButton ;
	private Action poSelectionAction;
	
	@Override
	protected void init() {
		// TODO Auto-generated method stub
		createAction() ;
		createFields();
		createLayout();
	}
	private void createFields(){
		submitButton = new PushButton (poSelectionAction);
		cancelButton = new PushButton ("cancelAction");
		
	}
	private void createLayout(){
		setHeader(createHeader());
		addField (createForm());
	}
	private FormHeader createHeader(){
		formHeader = new FormHeader();
		formHeader.setTitle("GeneratePurchaseOrder");
		return formHeader ;
	}
	private GroupControl createForm(){
		GroupControl form = new GroupControl();
		form.addField(new AutoGeneratePOField("AutoGeneratePO"),NORTH);
		form.addField(createButtons(),SOUTH);
		return form ;
	}
	private GroupControl createButtons(){
		GroupControl buttons = new GroupControl();
		buttons.setLayout(new FlowLayout(FlowLayout.RIGHT));
		buttons.addField(submitButton);
		buttons.addField(cancelButton);
		return buttons ;
	}
	
	private void createAction(){
		poSelectionAction = new POSelectionAction();
	}
}
